package com.lanou.controller;

import com.lanou.service.CourseTypeService;
import com.lanou.service.CrmClassService;
import com.lanou.service.ReferService;
import com.lanou.utils.AjaxResult;
import com.lanou.utils.DebugUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by dllo on 18/4/16.
 */
@Controller
public class ReferController {
    @Resource
    private ReferService referService;
    @Resource
    private CourseTypeService courseTypeService;
    @Resource
    private CrmClassService crmClassService;

    /**
     * 咨询学生管理-添加
     *
     * @param name
     * @param telephone
     * @param qq
     * @param intentionLevel
     * @param courseTypeId
     * @param classId
     * @param source
     * @param remark
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/insertRefer")
    public AjaxResult insertRefer(@RequestParam(value = "name") String name,
                                  @RequestParam(value = "telephone") String telephone,
                                  @RequestParam(value = "qq") String qq,
                                  @RequestParam(value = "intentionLevel") String intentionLevel,
                                  @RequestParam(value = "courseTypeId") String courseTypeId,
                                  @RequestParam(value = "classId") String classId,
                                  @RequestParam(value = "source") String source,
                                  @RequestParam(value = "remark") String remark) {
        DebugUtil.sout(name);
        DebugUtil.sout(telephone);
        DebugUtil.sout(qq);
        DebugUtil.sout(intentionLevel);
        DebugUtil.sout(courseTypeId);
        DebugUtil.sout(classId);
        DebugUtil.sout(source);
        DebugUtil.sout(remark);
        return referService.insertStuInfo(name, telephone, qq, intentionLevel, courseTypeId, classId, source, remark);

    }

    /**
     * 咨询学生管理-动态课程
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/showSubject")
    public AjaxResult showSubject() {
        return courseTypeService.selectAllInfo();
    }

    /**
     * 咨询学生管理-动态班级
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/showClasses")
    public AjaxResult showClasses(@RequestParam(value = "couresTypeId") String couresTypeId) {
        return crmClassService.selectAllClass(couresTypeId);
    }
}
